/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tesauro;

/**
 * An algorithm produced by Professor Daniel J. Bernstein and shown first to the world on the 
 * usenet newsgroup comp.lang.c. It is one of the most efficient hash functions ever published. 
 * 
 * @author demian
 */
public class DJBStringHashCode implements IHashCodeStrategy {
    public int hash(String palabra) {
        long hash = 5381;

        for(int i = 0; i < palabra.length(); i++)
        {
            hash = ((hash << 5) + hash) + palabra.charAt(i);
        }

        return (int)hash;        
    }
}
